/************************************************************
   Copyright 2008 Abhinav Pobbati

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*************************************************************/

#pragma once

#pragma unmanaged
#include <Common/Base/Container/Array/hkArray.h>
#include <Common/Base/Container/Array/hkObjectArray.h>
#pragma managed

using System::Collections::Generic::List;

namespace Havok4Xna {

	/// <summary>
	/// An array of pointers
	/// </summary>
	generic <class T> where T:INativeReference
	public ref class HkArray {
	public:
		HkArray();
		HkArray(int size);
		
		void Clear();
		void OptimizeCapacity(int numFreeElemsLeft);
		void OptimizeCapacity(int numFreeElemsLeft, bool exact);
		void RemoveAt(int index);
		void RemoveAtAndCopy(int index);
		int IndexOf(T element);
		int LastIndexOf(T element);
		void PopBack();
		void PopBack(int numElementsToRemove);
		void PushBack(T element);
		void PushBackUnchecked(T element);
		void Reserve(int n);
		void ReserveExactly(int n);
		void SetSizeUnchecked(int size);
		void InsertAt(int index, T element);

		DECLARE_PROPERTY_GETSET(int, Size)
		DECLARE_PROPERTY_GET(int, Capacity)
		DECLARE_PROPERTY_GET(bool, IsEmpty)
		DECLARE_PROPERTY_GETSET(bool, Locked)

		property T default[int] {
			T get(int index);
			void set(int index, T element);
		}

	internal:
		!HkArray();

	private:
		List<T> ^_list;
		hkArray<void*> *_array;
	};
}
